import { IsString, IsNumberString ,IsNotEmpty,Length, IsNumber, IsBoolean, isNumber, IsArray} from 'class-validator';
import { ApiProperty, PartialType} from '@nestjs/swagger';
import { MongodbId, PageAndSize } from 'src/common/common.dto';
export class AdminUser {
	@ApiProperty({
		description:"用户id",
		type:String
	})
    _id:       string;
	@ApiProperty({
		description:"用户昵称",
		type:String
	})
    nickName:  string;
	@ApiProperty({
		description:"用户账号",
		type:String
	})
    userName:  string;
	@ApiProperty({
		description:"用户类型",
		type:String
	})
    userType:  string;
	@ApiProperty({
		description:"用户头像",
		type:String
	})
    avatarUrl: string;
	@ApiProperty({
		description:"用户性别",
		type:String
	})
    gender:    number;
	@ApiProperty({
		description:"真实名称",
		type:String
	})
    realName:  string;
	@ApiProperty({
		description:"手机号",
		type:String
	})
    phone:     string;
	@ApiProperty({
		description:"手机号",
		type:[String]
	})
    access:     string[];
	@ApiProperty({
		description:"状态",
		type:String
	})
    status:    string;
	@ApiProperty({
		description:"创建时间",
		type:String
	})
    createdAt: Date;
	@ApiProperty({
		description:"最后更新时间",
		type:String
	})
    updatedAt: Date;
}

/**登录参数 */
export class AdminLoginDto {
	@ApiProperty({
		description:"用户名"
	})
	@IsString()
	@IsNotEmpty()
	userName:string;

	@ApiProperty({
		description:"密码"
	})
	@IsString()
	@IsNotEmpty()
	passWord:string;
}

/**新增用户的实体 */
export class AddUser {
	@ApiProperty({
		description:"用户名称"
	})
	@IsString()
	@IsNotEmpty()
	@Length(4,20)
	userName: string;

	@ApiProperty({
		description:"用户密码"
	})
	@IsString()
	@IsNotEmpty()
	@Length(4,20)
	passWord: string;

	@ApiProperty({
		description:"用户名称"
	})
	@IsString()
	@IsNotEmpty()
	@Length(2,8)
	nickName: string;

	// @ApiProperty({
	// 	description:"用户头像"
	// })
	// @IsString()
	// avatar: string;

	// @ApiProperty({
	// 	description:"用户权限",
	// 	type:[String]
	// })
	// @IsArray()
	// access: string[];
}

/**编辑用户的实体 */
export class EditUser extends PartialType(AdminUser){

}

/**删除用户的实体 */
export class UserId extends MongodbId{

}


export class AdminLoginRes {
	@ApiProperty({
		description:"用户对象",
		type:()=>AdminUser
	})
    user: AdminUser;
	@ApiProperty({
		description:"token"
	})
    token:string;
}

export class QueryAdminUserDto extends PageAndSize{
	@ApiProperty({
		type:String,
		description:"区服名称",
		required:false
	})
	nickName: string;
}
